/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TableModels;

import Entities.Administrator;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author tuanba_b00920
 */
public class AdminTableModel extends AbstractTableModel{
    ArrayList<Administrator> arrList;

    public AdminTableModel(ArrayList<Administrator> arrList) {
        this.arrList=arrList;
    }

    @Override
    public int getRowCount() {
       return arrList.size();
    }

    @Override
    public int getColumnCount() {
        return 10;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Administrator objAdmin=arrList.get(rowIndex);
        Object value=null;
      switch(columnIndex)
      {
         case 0:
              value =objAdmin.getId();
              break;
          case 1:
               value=objAdmin.getName();
              break;
      
          case 2:
              value=objAdmin.getUserName();
              break;
          case 3:
              value=objAdmin.getPassWord();
              break;
          case 4:
              value=objAdmin.getEmail();
              break;
          case 5:
              value=objAdmin.getUserType();
              break;
          case 6:
              //value=objAdmin.getStatus();
              if(objAdmin.getStatus() == 1){
                value = "Normal";
              }else{
                value = "Block";
              }
              break;
          case 7:
               value=objAdmin.getRegisterDate();
               break;
          case 8:
              value=objAdmin.getLastvisitDate();
              break;
          case 9:
              value=objAdmin.getModifiedDate();
              break;
      }
      return value;
    }
      @Override
    public String getColumnName(int column) {
        String colName = "";
        switch(column){
            case 0:
                colName = "ID";
                break;
            case 1:
                colName = "Name";
                break;
           case 2:
                colName = "UserName";
                break;
            case 3:
                colName = "Password";
                break;
            case 4:
                colName = "Email";
                break;
            case 5:
                colName = "UserType";
                break;
            case 6:
                colName = "Status";
                break;
             case 7:
                colName = "RegisterDate";
                break;
             case 8:
                colName = "Lastvistited Date";
                break;
            case 9:
                colName = "Modified Date";
                break;


        }
        return colName;
    }
  public Administrator Getvalue(int index){
  return arrList.get(index);
  }
}
